### GENERATING TABLES B.2 AND C.5: POLICY EXPERIMENT ATES

### USES PNAS DATASET

### REQUIRED PACKAGES
require(multiwayvcov)
require(lmtest)
require(stargazer)


### SUBSETTING FOR POLICY EXPERIMENT, REMOVING "WINDOW" TREATMENT, CREATING RESTRICTSUB

restrictsub <- subset(pnas, video.restrict==1 | video.control==1)
restrictsub$restrict.dum <- 0
restrictsub$restrict.dum[which(restrictsub$video.restrict==1)] <- 1
restrictsub$ed.factor <- as.factor(restrictsub$ed.1)
restrictsub$ed.parish <- paste(restrictsub$ed.1, restrictsub$parish, sep=".")


#ATES 
#ABILITY
dynamic.ability <- lm(ability.abroad.post.rev~ restrict.dum + factor(parish), data=restrictsub)
summary(dynamic.ability)
dynamic.ability.clust <- cluster.vcov(dynamic.ability, restrictsub$ed.parish)
dynamic.ability.mcse <- coeftest(dynamic.ability, dynamic.ability.clust)
dynamic.ability.mcse


#ASPIRATION
dynamic.aspire <- lm(aspire.abroad.post~ restrict.dum +factor(parish), data=restrictsub)
summary(dynamic.aspire)
dynamic.aspire.clust <- cluster.vcov(dynamic.aspire, restrictsub$ed.parish)
dynamic.aspire.mcse <- coeftest(dynamic.aspire, dynamic.aspire.clust)
dynamic.aspire.mcse

#TABLES

#for coefficients
stargazer(dynamic.ability.mcse, dynamic.aspire.mcse, align=TRUE, column.labels=c("Ability", "Aspiration"), 
          omit.stat=c("LL","ser","f"), title="Ability and Aspiration to Migrate",single.row=FALSE)

#for n
stargazer(dynamic.ability, dynamic.aspire, align=TRUE, column.labels=c("Ability", "Aspiration"), 
          omit.stat=c("LL","ser","f"), title="Ability and Aspiration to Migrate",single.row=FALSE)

